#include "SPHUD.h"

//----------------------------------------------------------------------
// SPSpriteRenderer
//----------------------------------------------------------------------
namespace SP
{
	class SPSpriteRenderer : public SPD3DObject
	{
	public:
		friend void SPDrawSprite( SPSprite* );
	protected:
		SPSpriteRenderer(){}
		virtual ~SPSpriteRenderer()
		{
			SAFE_RELEASE( m_pVertexLayout );
			SAFE_RELEASE( m_pVertexShader );
			SAFE_RELEASE( m_pPixelShader );
			SAFE_RELEASE( m_pPixelShaderColour );

			SAFE_RELEASE( m_pBlendState );
			SAFE_RELEASE( m_pDepthStencilState );
			SAFE_RELEASE( m_pRasterizerState );
			SAFE_RELEASE( m_pSamplerLinear );
		}

		HRESULT Create();		
		void Render( SPSprite* pSprite );

		ID3D11InputLayout*	m_pVertexLayout;

		ID3D11VertexShader* m_pVertexShader;
		ID3D11PixelShader* m_pPixelShader;
		ID3D11PixelShader* m_pPixelShaderColour;

		ID3D11BlendState* m_pBlendState;
		ID3D11DepthStencilState* m_pDepthStencilState;
		ID3D11RasterizerState* m_pRasterizerState;		
		ID3D11SamplerState* m_pSamplerLinear;
	};

	HRESULT SPSpriteRenderer::Create()
	{
		HRESULT hr;

		ID3DBlob* pVSBlob = NULL;
		ID3DBlob* pPSBlob1 = NULL;
		ID3DBlob* pPSBlob2 = NULL;

		// Create the shaders
		D3D_SHADER_MACRO defines1[] = { { 0 } };
		D3D_SHADER_MACRO defines2[] = { { "COLOUR_ONLY", " " }, { 0 } };

		V_RETURN( SPGetRenderEnvironment()->CompileShaderFromFile( L"hlsl\\Sprite.hlsl", NULL, "VSMain", "vs_5_0", &pVSBlob ) );
		V_RETURN( SPGetRenderEnvironment()->CompileShaderFromFile( L"hlsl\\Sprite.hlsl", defines1, "PSMain", "ps_5_0", &pPSBlob1 ) );
		V_RETURN( SPGetRenderEnvironment()->CompileShaderFromFile( L"hlsl\\Sprite.hlsl", defines2, "PSMain", "ps_5_0", &pPSBlob2 ) );

		V_RETURN( m_pDevice->CreateVertexShader( pVSBlob->GetBufferPointer(  ), pVSBlob->GetBufferSize(  ), NULL, &m_pVertexShader ) );
		V_RETURN( m_pDevice->CreatePixelShader( pPSBlob1->GetBufferPointer(  ), pPSBlob1->GetBufferSize(  ), NULL, &m_pPixelShader ) );
		V_RETURN( m_pDevice->CreatePixelShader( pPSBlob2->GetBufferPointer(  ), pPSBlob2->GetBufferSize(  ), NULL, &m_pPixelShaderColour ) );

		// Define the input layout
		D3D11_INPUT_ELEMENT_DESC layout[] =
		{
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "COLOUR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};
		UINT numElements = ARRAYSIZE( layout );
		// Create the input layout
		V_RETURN( m_pDevice->CreateInputLayout( layout, numElements, pVSBlob->GetBufferPointer(  ),
			pVSBlob->GetBufferSize(  ), &m_pVertexLayout ) );

		SAFE_RELEASE( pVSBlob );
		SAFE_RELEASE( pPSBlob1 );
		SAFE_RELEASE( pPSBlob2 );

		// Create the depth stencil state
		D3D11_DEPTH_STENCIL_DESC DSDesc;
		ZeroMemory( &DSDesc, sizeof( D3D11_DEPTH_STENCIL_DESC ) );
		DSDesc.DepthEnable = FALSE;
		DSDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
		DSDesc.DepthFunc = D3D11_COMPARISON_LESS;
		DSDesc.StencilEnable = FALSE;
		V_RETURN( m_pDevice->CreateDepthStencilState( &DSDesc, &m_pDepthStencilState ) );


		// Create the rasterizer state
		D3D11_RASTERIZER_DESC RSDesc;
		RSDesc.AntialiasedLineEnable = FALSE;
		RSDesc.CullMode = D3D11_CULL_BACK;
		RSDesc.DepthBias = 0;
		RSDesc.DepthBiasClamp = 0.0f;
		RSDesc.DepthClipEnable = TRUE;
		RSDesc.FillMode = D3D11_FILL_SOLID;
		RSDesc.FrontCounterClockwise = FALSE;
		RSDesc.MultisampleEnable = TRUE;
		RSDesc.ScissorEnable = FALSE;
		RSDesc.SlopeScaledDepthBias = 0.0f;

		V_RETURN( m_pDevice->CreateRasterizerState( &RSDesc, &m_pRasterizerState ) );
		
		
		// Create the blend state
		D3D11_BLEND_DESC BSDesc;
		ZeroMemory( &BSDesc, sizeof( D3D11_BLEND_DESC ) );

		BSDesc.RenderTarget[0].BlendEnable = TRUE;
		BSDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
		BSDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
		BSDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
		BSDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
		BSDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
		BSDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
		BSDesc.RenderTarget[0].RenderTargetWriteMask = 0x0F;

		V_RETURN( m_pDevice->CreateBlendState( &BSDesc, &m_pBlendState ) );


		// Create the sample state
		D3D11_SAMPLER_DESC SamDesc;
		ZeroMemory( &SamDesc, sizeof( SamDesc ) );
		SamDesc.Filter = D3D11_FILTER_ANISOTROPIC;
		SamDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
		SamDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
		SamDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
		SamDesc.MaxAnisotropy = 16;
		SamDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
		SamDesc.BorderColor[0] = SamDesc.BorderColor[1] = SamDesc.BorderColor[2] = SamDesc.BorderColor[3] = 0;
		SamDesc.MinLOD = 0;
		SamDesc.MaxLOD = D3D11_FLOAT32_MAX;
		V_RETURN( m_pDevice->CreateSamplerState( &SamDesc, &m_pSamplerLinear ) );

		return S_OK;
	}

	void SPSpriteRenderer::Render( SPSprite* pSprite )
	{
		UINT stride = sizeof( SPSprite::VERTEX );
		UINT offset = 0;	
		m_pImmediateContext->IASetVertexBuffers( 0, 1, &pSprite->m_pVB, &stride, &offset );
		m_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
		m_pImmediateContext->RSSetState( m_pRasterizerState );
		float vBlendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
		m_pImmediateContext->OMSetBlendState( m_pBlendState, vBlendFactor, 0xFFFFFFFF );
		m_pImmediateContext->OMSetDepthStencilState( m_pDepthStencilState, 0 );
		m_pImmediateContext->IASetInputLayout( m_pVertexLayout );
		m_pImmediateContext->VSSetShader( m_pVertexShader, 0, 0 );
		m_pImmediateContext->GSSetShader( NULL, NULL, 0 );

		if ( pSprite->m_pTex )
		{
			m_pImmediateContext->PSSetSamplers( 0, 1, &m_pSamplerLinear );
			m_pImmediateContext->PSSetShaderResources( 0, 1, &pSprite->m_pTex );
			m_pImmediateContext->PSSetShader( m_pPixelShader, 0, 0 );	
		}
		else
		{
			m_pImmediateContext->PSSetShader( m_pPixelShaderColour, 0, 0 );
		}

		m_pImmediateContext->Draw( 6, 0 );
	}

	void SPDrawSprite( SPSprite* pSprite )
	{
		static SPSpriteRenderer staticSPSR;
		static bool bCreate = false;
		if ( !bCreate )
		{
			staticSPSR.Create();
			bCreate = true;
		}
		staticSPSR.Render( pSprite );
	}
}

//----------------------------------------------------------------------
// SPFontSpriteRenderer
//----------------------------------------------------------------------
namespace SP
{
	class SPFontSpriteRenderer : public SPSpriteRenderer
	{
		friend void SPDrawFont( SPFontSprite* );
	protected:
		struct CB
		{
			XMFLOAT4 vColour;
		};

		SPFontSpriteRenderer(){}
		virtual ~SPFontSpriteRenderer()
		{			
			SAFE_RELEASE( m_pSRVFont );
		}

		HRESULT Create();
		void DrawFont( SPFontSprite* );

		ID3D11Buffer* m_pCB;
		ID3D11ShaderResourceView* m_pSRVFont;
	};


	HRESULT SPFontSpriteRenderer::Create()
	{
		HRESULT hr;

		SPSpriteRenderer::Create();

		SAFE_RELEASE( m_pVertexLayout );
		SAFE_RELEASE( m_pVertexShader );
		SAFE_RELEASE( m_pPixelShader );
		SAFE_RELEASE( m_pPixelShaderColour );

		ID3DBlob* pVSBlob = NULL;
		ID3DBlob* pPSBlob = NULL;

		V_RETURN( SPGetRenderEnvironment()->CompileShaderFromFile( L"hlsl\\FontSprite.hlsl", NULL, "VSMain", "vs_5_0", &pVSBlob ) );
		V_RETURN( SPGetRenderEnvironment()->CompileShaderFromFile( L"hlsl\\FontSprite.hlsl", NULL, "PSMain", "ps_5_0", &pPSBlob ) );

		V_RETURN( m_pDevice->CreateVertexShader( pVSBlob->GetBufferPointer(  ), pVSBlob->GetBufferSize(  ), NULL, &m_pVertexShader ) );
		V_RETURN( m_pDevice->CreatePixelShader( pPSBlob->GetBufferPointer(  ), pPSBlob->GetBufferSize(  ), NULL, &m_pPixelShader ) );

		// Define the input layout
		D3D11_INPUT_ELEMENT_DESC layout[] =
		{
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};
		UINT numElements = ARRAYSIZE( layout );
		// Create the input layout
		V_RETURN( m_pDevice->CreateInputLayout( layout, numElements, pVSBlob->GetBufferPointer(  ),
			pVSBlob->GetBufferSize(  ), &m_pVertexLayout ) );

		SAFE_RELEASE( pVSBlob );
		SAFE_RELEASE( pPSBlob );

		V_RETURN( SPGetRenderEnvironment()->CreateSRVFromFile( L"Font.dds", &m_pSRVFont ) );

		// Constant buffer
		D3D11_BUFFER_DESC Desc;
		Desc.Usage = D3D11_USAGE_DYNAMIC;
		Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
		Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
		Desc.MiscFlags = 0;
		Desc.ByteWidth = sizeof( CB );
		V_RETURN( m_pDevice->CreateBuffer( &Desc, NULL, &m_pCB ) );

		return S_OK;
	}

	void SPFontSpriteRenderer::DrawFont( SPFontSprite* pFontSprite )
	{
		HRESULT hr;

		m_pImmediateContext->IASetInputLayout( m_pVertexLayout );
		UINT stride = sizeof( XMFLOAT3 ) + sizeof( XMFLOAT2 );
		UINT offset = 0;
		m_pImmediateContext->IASetVertexBuffers( 0, 1, &pFontSprite->m_pVB, &stride, &offset );
		m_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
		m_pImmediateContext->VSSetShader( m_pVertexShader, 0, 0 );
		m_pImmediateContext->PSSetShader( m_pPixelShader, 0, 0 );

		m_pImmediateContext->RSSetState( m_pRasterizerState );
		float vBlendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
		m_pImmediateContext->OMSetBlendState( m_pBlendState, vBlendFactor, 0xFFFFFFFF );
		m_pImmediateContext->OMSetDepthStencilState( m_pDepthStencilState, 0 );

		m_pImmediateContext->PSSetSamplers( 0, 1, &m_pSamplerLinear );
		m_pImmediateContext->PSSetShaderResources( 0, 1, &m_pSRVFont );

		D3D11_MAPPED_SUBRESOURCE MappedResource;
		V( m_pImmediateContext->Map( m_pCB, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource ) );
		CB* pCB = ( CB* )MappedResource.pData;
		pCB->vColour = pFontSprite->m_vColour;
		m_pImmediateContext->Unmap( m_pCB, 0 );
		m_pImmediateContext->PSSetConstantBuffers( 0, 1, &m_pCB );

		m_pImmediateContext->Draw( pFontSprite->m_nDrawCount, 0 );
	}

	void SPDrawFont( SPFontSprite* pFontSprite )
	{
		static SPFontSpriteRenderer staticSPFR;
		static bool bCreate = false;
		if ( !bCreate )
		{
			staticSPFR.Create();
			bCreate = true;
		}
		staticSPFR.DrawFont( pFontSprite );
	}
}

//----------------------------------------------------------------------
// SPSprite
//----------------------------------------------------------------------
namespace SP
{
	SPSprite::SPSprite()
	{
		m_pTex = NULL;
		
		m_vertices[0] = VERTEX( XMFLOAT3(  1.0f,  1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ), XMFLOAT2( 1.0f, 0.0f ) ); // right top
		m_vertices[1] = VERTEX( XMFLOAT3(  1.0f, -1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ), XMFLOAT2( 1.0f, 1.0f ) ); // right bottom
		m_vertices[2] = VERTEX( XMFLOAT3( -1.0f, -1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ), XMFLOAT2( 0.0f, 1.0f ) ); // left bottom

		m_vertices[3] = VERTEX( XMFLOAT3( -1.0f, -1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ), XMFLOAT2( 0.0f, 1.0f ) ); // left bottom
		m_vertices[4] = VERTEX( XMFLOAT3( -1.0f,  1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ), XMFLOAT2( 0.0f, 0.0f ) ); // left top
		m_vertices[5] = VERTEX( XMFLOAT3(  1.0f,  1.0f, 0.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ), XMFLOAT2( 1.0f, 0.0f ) ); // right top

		HRESULT hr;
		V( SPGetRenderEnvironment()->CreateBuffer( sizeof(VERTEX), 6, m_vertices, &m_pVB ) );
		V( SPGetRenderEnvironment()->CreateSRVFromFile( L"cup.jpg", &m_pTex ) );
		
		SetRect( XMFLOAT4( 0.5, 0.1, 0.6, 1.0 ) );
	}

	SPSprite::~SPSprite()
	{
		SAFE_RELEASE( m_pVB );
		SAFE_RELEASE( m_pTex );
	}

	void SPSprite::Draw()
	{
		SPDrawSprite( this );
	}

	void SPSprite::SetRect( const XMFLOAT4& rect )
	{
		float L = rect.x * 2 - 1.0f;
		float T = (1.0f - rect.y) * 2 - 1.0f;
		float R = rect.z * 2 - 1.0f;
		float B = (1.0f - rect.w) * 2 - 1.0f;

		m_vertices[0].pos = XMFLOAT3( R, T, 0.0f );// right top
		m_vertices[1].pos = XMFLOAT3( R, B, 0.0f );// right bottom
		m_vertices[2].pos = XMFLOAT3( L, B, 0.0f );// left bottom

		m_vertices[3].pos = XMFLOAT3( L, B, 0.0f );// left bottom
		m_vertices[4].pos = XMFLOAT3( L, T, 0.0f );// left top
		m_vertices[5].pos = XMFLOAT3( R, T, 0.0f );// right top
		
		m_pImmediateContext->UpdateSubresource( m_pVB, 0, 0, m_vertices, 0, 0 );
	}

	void SPSprite::SetColour( const XMFLOAT4& c )
	{
		for ( int i = 0; i < 6; i++ )
		{
			m_vertices->colour = c;
		}
		m_pImmediateContext->UpdateSubresource( m_pVB, 0, 0, m_vertices, 0, 0 );
	}
}

//----------------------------------------------------------------------
// SPFontSprite
//----------------------------------------------------------------------
namespace SP
{
	void SPFontSprite::SetZero()
	{
		m_pVertices = NULL;
		m_pText = NULL;
		m_pVB = NULL;

		SetGlyphSize( XMFLOAT2(0.02f, 0.06f) );
		SetScreenRect( XMFLOAT4(0.01f, 1.0f, 1.0f, 0.5f), true );
		SetColour( XMFLOAT4(0.3f, 0.3f, 1.0f, 1.0f) );
	}

	SPFontSprite::SPFontSprite( WCHAR* str )
	{
		SetZero();
		if ( str )
			Create( wcslen(str), str );
		else
			Create( 0 );
	}

	SPFontSprite::SPFontSprite( UINT maxLetter )
	{
		SetZero();
		Create( maxLetter );
	}

	void SPFontSprite::Release()
	{
		SAFE_DELETE( m_pVertices );
		SAFE_DELETE( m_pText );

		SAFE_RELEASE( m_pVB );
	}

	SPFontSprite::~SPFontSprite()
	{
		Release();
	}

	void SPFontSprite::Create( UINT maxChar, WCHAR* str /* = NULL */ )
	{
		HRESULT hr;

		Release();
		m_nMaxLetter = maxChar;
		m_pText = new WCHAR[m_nMaxLetter];//WCHAR[m_nMaxLetter + 1];
		m_pVertices = new VERTEX[m_nMaxLetter * 6];

		if ( str )
		{			
			m_nNumChar = wcslen( str );
			CopyMemory( m_pText, str, sizeof(WCHAR) * m_nNumChar );
			//wcscpy_s( m_pText, m_nNumChar+1, str );
		}
		else
		{
			m_nNumChar = 0;
		}

		BulidVertices();
		V( SPGetRenderEnvironment()->CreateBuffer( sizeof( VERTEX ), m_nMaxLetter * 6, m_pVertices, &m_pVB ) );
	}

	void SPFontSprite::Draw()
	{
		SPDrawFont( this );
	}

	void SPFontSprite::TextRebuild( WCHAR* str )
	{
		UINT numChar = wcslen( str );
		if ( numChar <= m_nMaxLetter )
		{
			m_nNumChar = numChar;
			CopyMemory( m_pText, str, sizeof(WCHAR) * m_nNumChar );
			//wcscpy_s( m_pText, m_nMaxLetter+1, str );
			BulidVertices();
			m_pImmediateContext->UpdateSubresource( m_pVB, 0, 0, m_pVertices, 0, 0 );
		}
		else
		{
			Create( numChar, str );
		}
	}

	void SPFontSprite::SetGlyphSize( const XMFLOAT2& vGlyphSize )
	{
		m_vGlyphSize = vGlyphSize;
	}

	void SPFontSprite::SetColour( const XMFLOAT4& vColour )
	{
		m_vColour = vColour;
	}

	void SPFontSprite::SetScreenRect( const XMFLOAT4& vSR,bool bCenter )
	{
		m_vRect = vSR;
		m_bCenter = bCenter;
	}

	void SPFontSprite::BulidVertices()
	{
		FLOAT fCharTexSizeX = 0.010526315f; // = 10.0f / 950.0f;

		FLOAT fGlyphSizeX = m_vGlyphSize.x;
		FLOAT fGlyphSizeY = m_vGlyphSize.y;
		FLOAT fRectLeft = m_vRect.x;
		FLOAT fRectTop = m_vRect.y;

		fRectLeft = fRectLeft * 2.0f - 1.0f;
		fRectTop = fRectTop * 2.0f - 1.0f;

		if ( m_bCenter ) 
		{
			float fRectRight = m_vRect.z;
			fRectRight = fRectRight * 2.0f - 1.0f;
			float fRectBottom = m_vRect.w;
			fRectBottom = fRectBottom * 2.0f - 1.0f;
			float fcenterx = ((fRectRight - fRectLeft) - (float)m_nNumChar*fGlyphSizeX) *0.5f;
			float fcentery = ((fRectTop - fRectBottom) - (float)1*fGlyphSizeY) *0.5f;
			fRectLeft += fcenterx ;    
			fRectTop -= fcentery;
		}

		FLOAT fOriginalLeft = fRectLeft;
		FLOAT fTexTop = 0.0f;
		FLOAT fTexBottom = 1.0f;

		FLOAT fDepth = 0.0f;

		m_nDrawCount = 0;
		for ( UINT i = 0; i < m_nNumChar; i++ )
		{
			if ( m_pText[i] == '\n' )
			{
				fRectLeft = fOriginalLeft;
				fRectTop -= fGlyphSizeY;
				continue;
			}
			if ( m_pText[i] < 32 || m_pText[i] > 126 )
				continue;

			int a = m_pText[i];
			FLOAT fRectRight = fRectLeft + fGlyphSizeX;
			FLOAT fRectBottom = fRectTop - fGlyphSizeY;
			FLOAT fTexLeft = ( m_pText[i] - 32 ) * fCharTexSizeX;
			FLOAT fTexRight = fTexLeft + fCharTexSizeX;
			// tri1
			m_pVertices[m_nDrawCount + 0] = VERTEX( XMFLOAT3( fRectLeft, fRectTop, fDepth ), XMFLOAT2( fTexLeft, fTexTop ) ); 
			m_pVertices[m_nDrawCount + 1] = VERTEX( XMFLOAT3( fRectRight, fRectTop, fDepth ), XMFLOAT2( fTexRight, fTexTop ) ); 
			m_pVertices[m_nDrawCount + 2] = VERTEX( XMFLOAT3( fRectLeft, fRectBottom, fDepth ), XMFLOAT2( fTexLeft, fTexBottom ) ); 
			// tri2
			m_pVertices[m_nDrawCount + 3] = VERTEX( XMFLOAT3( fRectRight, fRectTop, fDepth ), XMFLOAT2( fTexRight, fTexTop ) ); 
			m_pVertices[m_nDrawCount + 4] = VERTEX( XMFLOAT3( fRectRight, fRectBottom, fDepth ), XMFLOAT2( fTexRight, fTexBottom ) ); 
			m_pVertices[m_nDrawCount + 5] = VERTEX( XMFLOAT3( fRectLeft, fRectBottom, fDepth ), XMFLOAT2( fTexLeft, fTexBottom ) ); 
			
			fRectLeft += fGlyphSizeX;
			m_nDrawCount += 6;
		}
	}

	void SPFontSprite::RebuildFrontSprite()
	{
		BulidVertices();
	}
}



//----------------------------------------------------------------------
// SPHUDObject
//----------------------------------------------------------------------
namespace SP
{
	SPHUDObject::SPHUDObject()
	{
		m_vRect = XMFLOAT4( 0.0f, 0.0f, 1.0f, 1.0f );
	}

	SPHUDObject::~SPHUDObject()
	{
		//
	}

}


//----------------------------------------------------------------------
// SPHUD
//----------------------------------------------------------------------
namespace SP
{
	SPHUD::SPHUD()
	{

	}

	SPHUD::~SPHUD()
	{

	}

	void SPHUD::Tick( float fElapsedTime )
	{
		std::list<SPHUDObject*>::iterator it = m_HUDObjectList.begin();
		for ( ; it != m_HUDObjectList.end(); it++ )
		{
			( *it )->Tick( fElapsedTime );
		}
	}

	void SPHUD::Draw()
	{ 
		std::list<SPHUDObject*>::iterator it = m_HUDObjectList.begin();
		for ( ; it != m_HUDObjectList.end(); it++ )
		{
			( *it )->Draw();
		}
	}

}
